<template>
  <div>
    <div class="tr" v-for="item in props.list" :key="item.id">
      <div class="td">
        <input type="checkbox" v-model="item.checked" />
      </div>
      <div class="td">
        {{ item.goodsname }}
      </div>
      <div class="td">
        {{ item.goodsprice }}
      </div>
      <div class="td">
        <button v-show="item.goodsnum > 1" @click="calc(item, -1)">-</button>
        {{ item.goodsnum }}
        <button @click="calc(item, 1)">+</button>
      </div>
      <div class="td">
        {{ item.goodsnum * item.goodsprice }}
      </div>
      <div class="td" @click="delById(item.id)">删除</div>
    </div>
  </div>
</template>

<script setup>
import { defineProps } from "vue";
let props = defineProps({
  list: {
    type: Array,
    default: () => [],
  },
});
const emits = defineEmits(["changeNum", "delitem"]);
let calc = (info, num) => {
  emits("changeNum", { item: info, num });
};
const delById = (id) => {
  emits("delitem", id);
};
</script>

<style></style>
